<!doctype html>
<html lang="en" xmlns:th="https://www.thymeleaf.org">

<!-- head -->
<div th:replace="~{include/include-head :: head}"></div>

<body>
<!-- topbar -->
<div th:replace="~{include/include-nav :: nav}"></div>

<div class="container-fluid">
    <div class="row">
        <!-- sidebar -->
        <div th:replace="~{include/include-sidebar :: sidebar}"></div>
        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
            <form th:action="@{/emp}" method="post">

                <!--						<input type="hidden" name="_method" value="put" th:if="${emp!=null}"/>-->
                <!--						<input type="hidden" name="id" th:if="${emp!=null}" th:value="${emp.id}"/>-->

                <input type="hidden" name="_method" value="put" th:if="${emp!=null}"/>
                <input type="hidden" name="id" th:if="${emp!=null}" th:value="${emp.empId}">


                <div class="form-group">
                    <label for="empName">EmpName</label>
                    <input name="empName" type="text" class="form-control" id="empName" placeholder="zhangsan" th:value="${emp!=null}?${emp.empName}">
                </div>
                <div class="form-group">
                    <label for="email">Email</label>
                    <input name="email" type="Email" class="form-control" id="email" placeholder="zhangsan@atguigu.com" th:value="${emp!=null}?${emp.email}">
                </div>
                <div class="form-group">
                    <label>gender</label>
                    <div class="form-check form-check-inline">
                        <input class="form‐check‐input" type="radio" name="gender" value="1" th:checked="${emp!=null}?${emp.gender==1}">
                        <label class="form‐check‐label">男</label>
                    </div>
                    <div class="form-check form-check-inline">
                        <input class="form‐check‐input" type="radio" name="gender" value="0" th:checked="${emp!=null}?${emp.gender==0}">
                        <label class="form‐check‐label">女</label>
                    </div>

                </div>
                <div class="form-group">
                    <label for="department">department</label>
                    <select class="form-control" id="department" name="department.dno">
                        <option th:selected="${emp!=null}?${dept.dno==emp.department.dno}" th:each="dept:${depts}" th:value="${dept.dno}" th:text="${dept.getDName()}">1</option>

                    </select>
                </div>

                <div class="form-group">
                    <label for="Birth">Birth</label>
                    <input name="birth" type="text" class="form-control" id="Birth" placeholder="zhangsan" th:value="${emp!=null}?${#dates.format(emp.date, 'yyyy-MM-dd HH:mm')}">
                </div>
                <button type="submit" class="btn btn-primary" th:text="${emp!=null}?'修改':'添加'">添加</button>
            </form>
        </main>
    </div>
</div>
<script src="dashboard.js" th:src="@{/js/main.js}"></script>
</body>
</html>